﻿using DevExpress.Xpo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Model.View
{
    [Persistent("vSaleSummary")]
    public class SaleSummary:XPLiteObject
    {
        public SaleSummary(Session session) : base(session) { }
        public override void AfterConstruction()
        {
            base.AfterConstruction();
        }
        P_Product fProductID;
        /// <summary>
        /// 货品
        /// </summary>
        public P_Product ProductID
        {
            get { return fProductID; }
            set { SetPropertyValue<P_Product>("ProductID", ref fProductID, value); }
        }
        decimal fQuantity;
        /// <summary>
        /// 数量
        /// </summary>
        [DbType("decimal(18,2)")]
        public decimal Quantity
        {
            get { return fQuantity; }
            set { SetPropertyValue<decimal>("Quantity", ref fQuantity, value); }
        }
        decimal fTurnoverPrice;
        /// <summary>
        /// 平均成交价
        /// </summary>
        [DbType("decimal(18,2)")]
        public decimal TurnoverPrice
        {
            get { return fTurnoverPrice; }
            set { SetPropertyValue<decimal>("TurnoverPrice", ref fTurnoverPrice, value); }
        }
        decimal fTurnoverAmount;
        public decimal TurnoverAmount
        {
            get { return fTurnoverAmount; }
            set { SetPropertyValue<decimal>("TurnoverAmount", ref fTurnoverAmount, value); }
        }
        decimal fSalePrice;
        /// <summary>
        /// 平均销售价
        /// </summary>
        public decimal SalePrice
        {
            get { return fSalePrice; }
            set { SetPropertyValue<decimal>("SalePrice", ref fSalePrice, value); }
        }
        decimal fSalePriceLowest;
        /// <summary>
        /// 平均最低销售价
        /// </summary>
        public decimal SalePriceLowest
        {
            get { return fSalePriceLowest; }
            set { SetPropertyValue<decimal>("SalePriceLowest", ref fSalePriceLowest, value); }
        }
        decimal fCostPrice;
        /// <summary>
        /// 平均成本价
        /// </summary>
        public decimal CostPrice
        {
            get { return fCostPrice; }
            set { SetPropertyValue<decimal>("CostPrice", ref fCostPrice, value); }
        }
    }
    public class SaleSummaryView
    {
        public SaleSummaryView(XPView view)
        {
            view.Properties.AddRange(new ViewProperty[]{
                new ViewProperty("ProductID.CategoryID.CategoryName",SortDirection.None,"[ProductID.CategoryID.CategoryName]",false,true),
                new ViewProperty("ProductID.BrandID.BrandName",SortDirection.None,"[ProductID.BrandID.BrandName]",false,true),
                new ViewProperty("ProductID.ProductCode",SortDirection.None,"ProductID.ProductCode",false,true),
                new ViewProperty("ProductID.ProductName",SortDirection.None,"ProductID.ProductName",false,true),
                new ViewProperty("ProductID.ProductSpec",SortDirection.None,"ProductID.ProductSpec",false,true),
                new ViewProperty("ProductID.Unit",SortDirection.None,"ProductID.Unit",false,true),
                new ViewProperty("Quantity",SortDirection.None,"[Quantity]",false,true),
                new ViewProperty("TurnoverPrice",SortDirection.None,"[TurnoverPrice]",false,true),
                new ViewProperty("TurnoverAmount",SortDirection.None,"[TurnoverAmount]",false,true),
                new ViewProperty("SalePrice",SortDirection.None,"[SalePrice]",false,true),
                new ViewProperty("SalePriceLowest",SortDirection.None,"[SalePriceLowest]",false,true),
                new ViewProperty("CostPrice",SortDirection.None,"[CostPrice]",false,true),
            });
        }
    }
}
